import pygame
import helpers
from collections import deque
from helpers import load_image
import numpy as np

class CommandShip(pygame.sprite.Sprite):

    name = "Command Ship"
    hull    = 100
    armor   = 100
    shields = 100

    player = None
    build_que = deque()
    current_build = None
    position = None
    health = 100
    max_health = 100
    
    def __init__(self, player, rect=None):
        pygame.sprite.Sprite.__init__(self)
        self.player = player
        self.image, self.rect = load_image('commandship.png', -1 )
        self.position = np.array([500,500])
    
    def draw(self, view_port, dt):
# Only draw a healthbar if we are not at maximum health
        BAR_HEIGHT = 3
        BAR_VOFFSET = 2
        if self.health < self.max_health:
            pygame.draw.line(view_port.screen, (255,255,255), 
                 (self.rect.left,self.rect.top-BAR_VOFFSET), 
                 (self.rect.right,self.rect.top-BAR_VOFFSET), BAR_HEIGHT)
            pygame.draw.line(view_port.screen, 
                 (0,255,0), (self.rect.left,self.rect.top-BAR_VOFFSET), 
                 (self.rect.left+(self.health/self.max_health)*self.rect.width,
                  self.rect.top-BAR_VOFFSET), BAR_HEIGHT)        
        
        self.rect.centerx = round(self.position[0] + view_port.topleft[0])
        self.rect.centery = round(self.position[1] + view_port.topleft[1])        
        view_port.screen.blit(self.image, self.rect)